package com.whsxt.config;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.profile.DefaultProfile;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: caoqingwen
 * @CreateTime: 2021-03-22 17:47
 * @Description:
 */
@EnableConfigurationProperties(value = SmsProperties.class)
@Configuration
public class SmsAutoConfiguration {


    @Autowired
    private SmsProperties smsProperties;


    /**
     * 初始化阿里的客户端
     *
     * @return
     */
    @Bean
    public IAcsClient iAcsClient() {
        DefaultProfile profile = DefaultProfile.getProfile(smsProperties.getRegionId(), smsProperties.getAccessKeyId(), smsProperties.getAccessSecret());
        /*try {
            DefaultProfile.addEndpoint(smsProperties.getRegionId(),smsProperties.getRegionId(),"Dysmsapi",smsProperties.getSysDomain());
        } catch (ClientException e) {
            e.printStackTrace();
        }*/
        return new DefaultAcsClient(profile);
    }


}
